var List  = []
import Mock from 'mockjs'
for(var i=0;i<200;i++){
    List.push({
        id:Mock.mock('@guid'),
        order:Mock.mock('@natural'),
        classification:'课程订单',
        title:Mock.mock('@integer(0, 2)'),
        money:Mock.mock('@integer(6000, 10000)'),
        state:'待支付',
        time:Mock.mock('@datetime')
    })
}
import { param2Obj } from '../utls/utilsDemo'
export default{
    getHomeData:(config)=>{
        console.log(config)
        // var orders = JSON.parse(config.body).order
        var {keyword,page,pageSize} = param2Obj(config.url)
        
        var newARr = List.filter(item=>item.order.toString().indexOf(keyword) != -1);

        var pageResult = newARr.filter((item,index)=>{
            return (page-1)*pageSize<=index && index<page*pageSize
        })
        return{
            code:200,
            msg:'请求成功',
            data:pageResult,
            total:List.length
        }
    },
    batchDeleteData1:config=>{
        console.log('config',config.body)
        var {ids} = JSON.parse(config.body)
        console.log(ids)
        var newArr = List.filter(item=>ids.indexOf(item.id) ==-1)
        List = newArr
        return{
            code:200,
            msg:'批量删除成功',
            data:null
        }
    }
}
